package ch.fusun.baron.coatofarms.ui.background;

import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;

import ch.fusun.baron.coatofarms.ui.COAColor;

/**
 * Plain background
 */
public class PlainBackground implements COABackground {

	private final COAColor color;

	/**
	 * @param color
	 *            The color
	 */
	public PlainBackground(COAColor color) {
		this.color = color;
	}

	@Override
	public void drawBackground(GC gc, int x, int y, int width, int height) {
		short[] rgb = color.getColorRGB();
		gc.setBackground(new Color(gc.getDevice(), rgb[0], rgb[1], rgb[2]));

		int left = x - width / 2;
		int right = x + width / 2;
		int bottom = y - height / 2;
		int top = y + height / 2;

		gc.fillRectangle(left, bottom, right, top);
	}

	@Override
	public String uniqueCode() {
		return "PlainBackground" + color;
	}
}
